package cn.t.persistence.mapper.order;

import cn.t.persistence.entity.order.OrderDetailPO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 领料订单明细表(OrderDetail)领域对象与实体对象转换
 *
 * @author l
 * @since 2024-05-24 10:18:10
 */

public interface OrderDetailMapper extends BaseMapper<OrderDetailPO> {

    /**
     * 批量插入领料订单明细
     * @param orderDetails 订单明细列表
     */
    @Insert("<script>" +
            "INSERT INTO t_order_detail(" +
            "order_sn, sku_code, sku_name, sku_img, category_id, category_name, qty," +
            "before_weight, after_weight, cargoway_id, order_transfer_status, error_rate, std_weight," +
            "is_deleted, modifier, creator, gmt_created, gmt_modified, tenant" +
            ") VALUES" +
            "<foreach item='item' index='index' collection='list' separator=','>" +
            "(#{item.orderSn}, #{item.skuCode}, #{item.skuName}, #{item.skuImg}," +
            "#{item.categoryId}, #{item.categoryName}, #{item.qty}," +
            "#{item.beforeWeight}, #{item.afterWeight}, #{item.cargowayId}," +
            "#{item.orderTransferStatus}, #{item.errorRate}, #{item.stdWeight}," +
            "#{item.isDeleted}, #{item.modifier}, #{item.creator}, #{item.gmtCreated}, #{item.gmtModified}, #{item.tenant})" +
            "</foreach>" +
            "</script>")
    int batchInsert(@Param("list") List<OrderDetailPO> orderDetails);
    //批量修改 qty,sku std_weight

}
